/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - resource
// Copyright( c) 2014.  All Rights Reserved
//
// File:		AETextureManager.inl
// Author:		Gianluca Belardelli
// Date:		24/10/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AETEXTUREMANAGER_INL_
#define _AETEXTUREMANAGER_INL_

AE_FORCEINLINE void AETextureManager::RegisterLoaderProvider( AETextureLoaderI *lpProvider )
{
	AEASSERT( lpProvider );
	DeRegisterLoaderProvider( lpProvider );

	AEASSERT_MSG( m_nProviderCount < AE_MAX_TEXTURE_LOADER, "Raggiunto numero massimo di AETextureFormatProviderI" );
	m_lpLoader[ m_nProviderCount++] = lpProvider;
}

AE_FORCEINLINE void AETextureManager::DeRegisterLoaderProvider( AETextureLoaderI *lpProvider )
{
	AEASSERT( lpProvider );

	int iCount = m_nProviderCount;
	m_nProviderCount = 0;
	
	for( int i=0;i<iCount;i++ )
		if( m_lpLoader[i] != lpProvider )
			m_lpLoader[ m_nProviderCount++ ] = m_lpLoader[i];
}

AE_FORCEINLINE AEINT32 AETextureManager::GetLoaderProviderCount( void ) const
{
	return m_nProviderCount;
}

AE_FORCEINLINE AETextureLoaderI &AETextureManager::GetLoaderProvider( AEINT32 nIndex ) const
{
	AEASSERT( nIndex >= 0 && nIndex < m_nProviderCount );
	return *m_lpLoader[ nIndex ];
}

#endif // _AETEXTUREMANAGER_INL_
